function flushCode(object) {
    // document.getElementById("code").src = "/code?date=" + new Date();
    // object.src="/code?date=" + new Date();
    $(object).attr("src", "/code?date=" + new Date());
}
// var 全局
//     let 局部
// const 常量
function login() {
    let username = $("#username").val();
    let password = $("#password").val();
    let code = $("#code").val();
    let reg = /^[a-zA-Z]\w{5,15}$/;
    if (!reg.test(username)) {
        alert("你输入用户名的格式不正确!");
        return;
    }
    if (!reg.test(password)) {
        alert("你输入密码的格式不正确!");
        return;
    }
    $.ajax({
        url: '/login',
        data: {username: username, password: password, code: code},
        type: 'post',
        dataType: 'json',
        success: function (data) {
            if (data.count == 1) {
                window.location.href = "/back/manage.html";
            } else if(data.count==0){
                alert("你输入的用户名或者密码不正确");
            }else if(data.count==-1){
                alert("你输入的验证码不正确");
            }
        }
    })

}